Imports System
Imports System.Data.OracleClient


'-----------------------------------------------------------------------------


Public Class cbadb01l

  Private Shared rvcn_conn As New OracleConnection
  Private rvcm_cmnd_objt As OracleCommand
  Private rvdt_data_tabl As DataTable

  Private rvin_rowx_cntx As Integer = 0
  Private rvin_rowx_indx As Integer = 0


  '-----------------------------------------------------------------------------


  Private Sub rvvd_getx_conn() 

    Dim lvst_exec_path As String
    Dim lvin_exec_path_lngh As Integer
    Dim lvst_binx_fldr_path As String

    Try

      If rvcn_conn.State <> ConnectionState.Open Then


        lvst_exec_path = System.Windows.Forms.Application.ExecutablePath
        lvin_exec_path_lngh = lvst_exec_path.LastIndexOf("\")
        lvst_binx_fldr_path = lvst_exec_path.Substring _
                               (0 _
                               , lvin_exec_path_lngh)
        'lvin_binx_fldr_path_lngt = lvst_binx_fldr_path.LastIndexOf("\")
        'lvst_data_base_path = lvst_binx_fldr_path.Substring _
        '                      (0 _
        '                      , lvin_binx_fldr_path_lngt)

        rvcn_conn.ConnectionString = "Data Source= " _
                                        & lvst_binx_fldr_path _
                                        & "\Database\cmdb.mdb;" & _
                                    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                    "Jet OLEDB:Database Password=MIKADO;"

        rvcn_conn.Open()


      End If

    Catch ex As Exception

      MessageBox.Show(ex.Message)

    End Try

  End Sub


  '-----------------------------------------------------------------------------


  Protected Sub tvvd_exec_cmnd _
                 (ByVal ivst_sqlx_strn As String)

    rvcm_cmnd_objt = New OracleCommand _
                          (ivst_sqlx_strn _
                          , rvcn_conn)
    Try

      rvcm_cmnd_objt.ExecuteNonQuery()

    Catch ex As Exception

    End Try

  End Sub


  '-----------------------------------------------------------------------------


  Protected Sub tvvd_exec_qury _
                  (ByVal ivst_sqlx_strn As String)

    Dim lvda_data_adpt As OracleDataAdapter

    rvdt_data_tabl = New DataTable

    rvin_rowx_indx = 0

    lvda_data_adpt = New OracleDataAdapter _
                          (ivst_sqlx_strn _
                          , rvcn_conn)
    Try

      lvda_data_adpt.Fill _
                          (rvdt_data_tabl)

    Catch ex As Exception

    End Try

    rvin_rowx_cntx = rvdt_data_tabl.Rows.Count

  End Sub


  '-------------------------------------------------------------------------


  Protected Sub tvvd_ftch_data_exst_cndn _
                  (ByRef orbl_data_exst_cndn As Boolean)

    If rvin_rowx_indx < rvin_rowx_cntx Then

      orbl_data_exst_cndn = True

      rvin_rowx_indx += 1

    Else

      orbl_data_exst_cndn = False

    End If

  End Sub


  '--------------------------------------------------------------------------------


  Protected Function tvst_getx_clmn_data _
                      (ByVal ivst_clmn_name As String) _
                       As String

    Dim lvst_clmn_data As String

    Try

      lvst_clmn_data = rvdt_data_tabl.Rows _
                                        (rvin_rowx_indx - 1) _
                                        (ivst_clmn_name)

    Catch ex As Exception

      If lvst_clmn_data Is Nothing Then

        lvst_clmn_data = ""

      End If

    End Try

    Return lvst_clmn_data

  End Function


  '----------------------------------------------------------------------------------


  Public Sub New()

    rvvd_getx_conn()

  End Sub


  '----------------------------------------------------------------------------------


  Protected Sub mPrDBDisconnect()
    If rvcn_conn.State = ConnectionState.Open Then
      rvcn_conn.Close()
    End If
  End Sub



End Class
